package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.History;
import com.sk.bilibili.dto.HistoryInfo;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.HistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @author 邵康
 * @date 2021/11/25 12:55
 */
@CrossOrigin
@RestController
@RequestMapping("/history")
@Api(tags = "历史")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    @ApiOperation("手动添加历史  防止重复添加  type  targetId  title必须")
    @PostMapping("/add")
    public R<Void> add(@RequestBody History history) {
        return historyService.add(history);
    }

    @ApiOperation("根据Id删除历史")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return historyService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(@RequestBody History history) {
        return historyService.update(history);
    }

    @ApiOperation("分页查看历史  跟搜索功能连锁了")
    @PostMapping("/pageSearch")
    public R<IPage<History>> pageSearch(@RequestBody HistoryInfo historyInfo) {
        return historyService.pageSearch(historyInfo);
    }

}
